package com.banyuan.lesson.thread;

/*
* Thread才是真正的线程；
* Runnable是线程的一个内核；*/
public class MyRunnable implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread() + "-" +i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyRunnable runnable = new MyRunnable();
        Thread th1 = new Thread(runnable);
        Thread th2 = new Thread(runnable);
        th1.start();
        th2.start();
        //会让th1的父线程（main方法）等待，直到th1执行完；
        //必须要在start之后，如果在之前并发失效；
        //可能会造成mian方法中不并发；
        th1.join();
        th2.join();
    }
}
